//
// Description: 205. 同构字符串
// Created by Loading on 2025/4/13.
//

#include <bits/stdc++.h>

using namespace std;

bool isIsomorphic(string s, string t) {
    unordered_map<char, char> s2t, t2s;

    for (int i = 0; i < s.size(); ++i) {
        if (s2t.count(s[i]) && s2t[s[i]] != t[i]) {
            return false;
        }
        if (t2s.count(t[i]) && t2s[t[i]] != s[i]) {
            return false;
        }
        s2t[s[i]] = t[i];
        t2s[t[i]] = s[i];
    }

    return true;
}

int main() {
    string s = "badc";
    string t = "baba";

    auto res = isIsomorphic(s, t);

    cout << res << endl;

    return 0;
}
